//
// NeL - bindings
// Copyright (C) 2010 Naush
//
//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU Affero General Public License as
//published by the Free Software Foundation, either version 3 of the
//License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU Affero General Public License for more details.
//
//You should have received a copy of the GNU Affero General Public License
//along with this program.  If not, see <http://www.gnu.org/licenses/>.

package org.ryzom.nel.misc;

public class CMemStream extends IStream {
  private long swigCPtr;

  public CMemStream(long cPtr, boolean cMemoryOwn) {
    super(nelmiscJNI.CMemStream_SWIGUpcast(cPtr), cMemoryOwn);
    swigCPtr = cPtr;
  }

  public static long getCPtr(CMemStream obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nelmiscJNI.delete_CMemStream(swigCPtr);
      }
      swigCPtr = 0;
    }
    super.delete();
  }

  public CMemStream(boolean inputStream, boolean stringmode, long defaultcapacity) {
    this(nelmiscJNI.new_CMemStream__SWIG_0(inputStream, stringmode, defaultcapacity), true);
  }

  public CMemStream(boolean inputStream, boolean stringmode) {
    this(nelmiscJNI.new_CMemStream__SWIG_1(inputStream, stringmode), true);
  }

  public CMemStream(boolean inputStream) {
    this(nelmiscJNI.new_CMemStream__SWIG_2(inputStream), true);
  }

  public CMemStream() {
    this(nelmiscJNI.new_CMemStream__SWIG_3(), true);
  }

  public CMemStream(CMemStream other) {
    this(nelmiscJNI.new_CMemStream__SWIG_4(CMemStream.getCPtr(other), other), true);
  }

  public CMemStream assign(CMemStream other) {
    return new CMemStream(nelmiscJNI.CMemStream_assign(swigCPtr, this, CMemStream.getCPtr(other), other), false);
  }

  public void swap(CMemStream other) {
    nelmiscJNI.CMemStream_swap(swigCPtr, this, CMemStream.getCPtr(other), other);
  }

  public void setStringMode(boolean stringmode) {
    nelmiscJNI.CMemStream_setStringMode(swigCPtr, this, stringmode);
  }

  public boolean stringMode() {
    return nelmiscJNI.CMemStream_stringMode(swigCPtr, this);
  }

  public String toString(boolean hexFormat) {
    return nelmiscJNI.CMemStream_toString(swigCPtr, this, hexFormat);
  }

  public String toString_c() {
    return nelmiscJNI.CMemStream_toString_c(swigCPtr, this);
  }

  public void serialBuffer(SWIGTYPE_p_unsigned_char buf, long len) {
    nelmiscJNI.CMemStream_serialBuffer(swigCPtr, this, SWIGTYPE_p_unsigned_char.getCPtr(buf), len);
  }

  public void serialBit(SWIGTYPE_p_bool bit) {
    nelmiscJNI.CMemStream_serialBit(swigCPtr, this, SWIGTYPE_p_bool.getCPtr(bit));
  }

  public boolean seek(int offset, SWIGTYPE_p_TSeekOrigin origin) {
    return nelmiscJNI.CMemStream_seek(swigCPtr, this, offset, SWIGTYPE_p_TSeekOrigin.getCPtr(origin));
  }

  public int getPos() {
    return nelmiscJNI.CMemStream_getPos(swigCPtr, this);
  }

  public int reserve(long len) {
    return nelmiscJNI.CMemStream_reserve(swigCPtr, this, len);
  }

  public void clear() {
    nelmiscJNI.CMemStream_clear(swigCPtr, this);
  }

  public long length() {
    return nelmiscJNI.CMemStream_length(swigCPtr, this);
  }

  public long size() {
    return nelmiscJNI.CMemStream_size(swigCPtr, this);
  }

  public SWIGTYPE_p_unsigned_char buffer() {
    long cPtr = nelmiscJNI.CMemStream_buffer(swigCPtr, this);
    return (cPtr == 0) ? null : new SWIGTYPE_p_unsigned_char(cPtr, false);
  }

  public void resetBufPos() {
    nelmiscJNI.CMemStream_resetBufPos(swigCPtr, this);
  }

  public void fill(SWIGTYPE_p_unsigned_char srcbuf, long len) {
    nelmiscJNI.CMemStream_fill(swigCPtr, this, SWIGTYPE_p_unsigned_char.getCPtr(srcbuf), len);
  }

  public void resize(long size) {
    nelmiscJNI.CMemStream_resize(swigCPtr, this, size);
  }

  public SWIGTYPE_p_unsigned_char bufferToFill(long msgsize) {
    long cPtr = nelmiscJNI.CMemStream_bufferToFill(swigCPtr, this, msgsize);
    return (cPtr == 0) ? null : new SWIGTYPE_p_unsigned_char(cPtr, false);
  }

  public void invert() {
    nelmiscJNI.CMemStream_invert(swigCPtr, this);
  }

  public void resetPtrTable() {
    nelmiscJNI.CMemStream_resetPtrTable(swigCPtr, this);
  }

  public void increaseBufferIfNecessary(long len) {
    nelmiscJNI.CMemStream_increaseBufferIfNecessary(swigCPtr, this, len);
  }

  public void serialCont(SWIGTYPE_p_std__vectorT_unsigned_char_t cont) {
    nelmiscJNI.CMemStream_serialCont__SWIG_7(swigCPtr, this, SWIGTYPE_p_std__vectorT_unsigned_char_t.getCPtr(cont));
  }

  public void serialCont(SWIGTYPE_p_std__vectorT_char_t cont) {
    nelmiscJNI.CMemStream_serialCont__SWIG_8(swigCPtr, this, SWIGTYPE_p_std__vectorT_char_t.getCPtr(cont));
  }

  public void serialCont(SWIGTYPE_p_std__vectorT_bool_t cont) {
    nelmiscJNI.CMemStream_serialCont__SWIG_9(swigCPtr, this, SWIGTYPE_p_std__vectorT_bool_t.getCPtr(cont));
  }

  public void serial(SWIGTYPE_p_unsigned_char b) {
    nelmiscJNI.CMemStream_serial__SWIG_6(swigCPtr, this, SWIGTYPE_p_unsigned_char.getCPtr(b));
  }
/*
  public void serial(SWIGTYPE_p_char b) {
    nelmiscJNI.CMemStream_serial__SWIG_7(swigCPtr, this, SWIGTYPE_p_char.getCPtr(b));
  }

  public void serial(SWIGTYPE_p_unsigned_int b) {
    nelmiscJNI.CMemStream_serial__SWIG_8(swigCPtr, this, SWIGTYPE_p_unsigned_int.getCPtr(b));
  }

  public void serial(SWIGTYPE_p_int b) {
    nelmiscJNI.CMemStream_serial__SWIG_9(swigCPtr, this, SWIGTYPE_p_int.getCPtr(b));
  }
*/
  public void serial(SWIGTYPE_p_unsigned_int b) {
    nelmiscJNI.CMemStream_serial__SWIG_10(swigCPtr, this, SWIGTYPE_p_unsigned_int.getCPtr(b));
  }

  public void serial(SWIGTYPE_p_int b) {
    nelmiscJNI.CMemStream_serial__SWIG_11(swigCPtr, this, SWIGTYPE_p_int.getCPtr(b));
  }

  public void serial(SWIGTYPE_p_unsigned_long_long b) {
    nelmiscJNI.CMemStream_serial__SWIG_12(swigCPtr, this, SWIGTYPE_p_unsigned_long_long.getCPtr(b));
  }

  public void serial(SWIGTYPE_p_long_long b) {
    nelmiscJNI.CMemStream_serial__SWIG_13(swigCPtr, this, SWIGTYPE_p_long_long.getCPtr(b));
  }

  public void serial(SWIGTYPE_p_float b) {
    nelmiscJNI.CMemStream_serial__SWIG_14(swigCPtr, this, SWIGTYPE_p_float.getCPtr(b));
  }

  public void serial(SWIGTYPE_p_double b) {
    nelmiscJNI.CMemStream_serial__SWIG_15(swigCPtr, this, SWIGTYPE_p_double.getCPtr(b));
  }

  public void serial(SWIGTYPE_p_bool b) {
    nelmiscJNI.CMemStream_serial__SWIG_16(swigCPtr, this, SWIGTYPE_p_bool.getCPtr(b));
  }

  public void serial(SWIGTYPE_p_char b) {
    nelmiscJNI.CMemStream_serial__SWIG_17(swigCPtr, this, SWIGTYPE_p_char.getCPtr(b));
  }

  public void serial(SWIGTYPE_p_std__string b) {
    nelmiscJNI.CMemStream_serial__SWIG_18(swigCPtr, this, SWIGTYPE_p_std__string.getCPtr(b));
  }

  public void serial(ucstring b) {
    nelmiscJNI.CMemStream_serial__SWIG_19(swigCPtr, this, ucstring.getCPtr(b), b);
  }

  public long serialSeparatedBufferIn(SWIGTYPE_p_unsigned_char buf, long len) {
    return nelmiscJNI.CMemStream_serialSeparatedBufferIn(swigCPtr, this, SWIGTYPE_p_unsigned_char.getCPtr(buf), len);
  }

  public void serialSeparatedBufferOut(SWIGTYPE_p_unsigned_char buf, long len) {
    nelmiscJNI.CMemStream_serialSeparatedBufferOut(swigCPtr, this, SWIGTYPE_p_unsigned_char.getCPtr(buf), len);
  }

  public void serialHex(SWIGTYPE_p_unsigned_int b) {
    nelmiscJNI.CMemStream_serialHex(swigCPtr, this, SWIGTYPE_p_unsigned_int.getCPtr(b));
  }

}
